<include file='Admin/Tpl/Public/nav.html' />
<style type="text/css">td{ text-align:center}</style>
    <div class="btn-group groups" style="float:right">
        <a href="javascript:void(0)" class="btn btn-danger sub_add" onclick="excel_import()">
            <i class="fa fa-plus"></i> 
            Excel导入
        </a>
    </div>
    <div class="add_bg" style="display:none;background:black;opacity:0.3;position:absolute;z-index:50;top:0px;left:0px;bottom:0px;width:100%;height:"></div>					
    <div class="add_data add_city the-box" style="display:none;border-radius:3px;position:absolute;z-index:100;left:30%;top:30%;" >
        <div class="sub sub_remove" style="float:right;font-size:25px;margin-top:-15px;">x</div>
        <h4 id="title_name">Excel导入:</h4>
        <form action="__URL__/excel_import" method="post" enctype="multipart/form-data">
        <div class="input"></div>	
        <br />
        <input type="submit" style="float:left;margin-right:5px;" class="sub sub_add btn btn-info" value="添加" /> 
        </form>
    </div>

    <div class="btn-group groups" style="float:right">
        <span type="button" class="btn btn-success" >
            <a style="color:white;font-weight:bold" href="__APP__/HomePage/audience_excel">
                Excel文件导出
            </a>
        </span>
    </div>
    <div class="sidebar-right-heading">
        <ul class="nav nav-tabs square nav-justified">
          <li class="active"><a href="#online-user-sidebar" data-toggle="tab"><i class="fa fa-comments"></i></a></li>
          <li><a href="#notification-sidebar" data-toggle="tab"><i class="fa fa-bell"></i></a></li>
          <li><a href="#task-sidebar" data-toggle="tab"><i class="fa fa-tasks"></i></a></li>
          <li><a href="#setting-sidebar" data-toggle="tab"><i class="fa fa-cogs"></i></a></li>
        </ul>
    </div>
    <div class="page-content">
        <div class="container-fluid">
            <br/>
            
			<div class="col-sm-3 left">
                <div class="the-box">
                	<h4>添加用户</h4>
                    <form id="ExampleBootstrapValidationForm" method="post" action="__URL__/addAct" enctype="multipart/form-data">
                        <div class="form-group">
                            <label>用户名 <span style="color:red">*</span></label>
                            <div>
                                <input type="text" class="form-control must" id="name" type="text" name="audience_username" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>密码 <span style="color:red">*</span></label>
                            <div>										
                                <input  class="form-control must" id="pwd" type="password" name="audience_pwd" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>确认密码 <span style="color:red">*</span></label>
                            <div>										
                                <input  class="form-control must" id="pwds" type="password" name="check_pwd" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>昵称 <span style="color:red">*</span></label>
                            <div>										
                                <input  class="form-control must" id="n_name" type="text" name="audience_name" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>昵称首字母 <span style="color:red">*</span></label>
                            <div>										
                                <input  class="form-control must" id="f_name" type="text" name="audience_nick" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>所属部门</label>
                            <div>										
                                <select class="form-control" tabindex="2" name="audience_department">
                                    <foreach name="department" item="value">
                                        <option value="{$value.department_id}">{$value.department_name}</option>
                                    </foreach>													
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>职位</label>
                            <div>										
                                <input  class="form-control" id="position" type="text" name="audience_position" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>手机</label>
                            <div>										
                                <input  class="form-control" id="tel" type="text" name="audience_tel" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>邮箱</label>
                            <div>										
                                <input  class="form-control" id="email" type="email" name="audience_email" pattern="^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>头像</label>
                            <div>										
                                <input id="portrait"  class="form-control"  type="file" name="audience_portrait" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label>所属权限</label>
                            <div>
                                <select class="form-control" tabindex="2" name="audience_rights">
                                    <option value="1">普通员工</option>
                                    <option value="2">一般管理员</option>
                                    <option value="3">超级管理员</option>	
                                </select>
                            </div>
                        </div>


                        <!--  李记辉  添加于2015/01/26 -->
                        <div class="form-group">
                            <label>所属会议类型分组</label>
                            <div>
                            <select class="form-control" tabindex="2" id="category_id" name="category_id">
                                    <foreach name="rs.meeting_category" item="value" >
                                        <option value="{$value.category_id}">{$value.category_name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <!--  李记辉  添加于2015/01/26 -->

                        <div class="form-group" name="check_rights" style="display:none">
                            <label>选择管理会议类型权限</label>
                            <div class="col-md-12 left">
                            <volist name='rs.meeting_category' id='val'>
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="meeting[]" value="{$val.category_id}"><span>{$val.category_name}</span>
                                </label>
                            </volist>
                            </div>
                        </div>
                        <div class="form-group">
                             <input class="btn btn-primary" id="submit"  type="submit" value="添加" />
                        </div>
                    </form>
                </div>
            </div>
            
			<div class="col-sm-9 right">
                <div class="the-box">
                    <div class="table-responsive div1 div_search">
                        <form class="navbar-form navbar-left" role="search" action="__URL__/index" method="get" name="searchform">
                            <div class="form-group">
                                <input type="text" class="form-control" name="seach" >
                                <input type="submit" value="搜索" >
                            </div>
                        </form><br>
                        <table class="table table-th-block table-hover">
                            <thead>
                                <tr>
                                    <td class="order" name='audience_portrait' width="80px" style="text-align:center">头像</td>
                                    <td class="order" name='audience_username' width="80px" style="text-align:center">用户名</td>
                                    <td class="order" name='audience_nick' 	   width="80px" style="text-align:center" style="cursor:pointer">姓名</td>
                                    <td class="order" name='audience_department' width="120px" style="text-align:center">部门</td>
                                    <td class="order" name='audience_position' style="text-align:center">职位</td>
                                    <td width="60px" style="text-align:center">操作</td>
                                </tr>
                            </thead>
                            <tbody>
                                <foreach name="rs.data" item="value">
                                    <tr>
                                        <td>
                                            <if condition="$value.audience_portrait eq null">
                                                <img src="/teamin/Public/Images/head.jpg" style="width:22px; height:22px;" class="avatar img-circle" alt="avatar">
                                            <else />
                                                <img src="/teamin/{$value.audience_portrait}" style="width:22px; height:22px;" class="avatar img-circle" alt="avatar">
                                            </if>
                                        </td>
                                        <td>{$value.audience_username}</td>
                                        <td>{$value.audience_name}</td>
                                        <td>{$value.audience_department}</td>
                                        <td>{$value.audience_position}</td>
                                        <td style="width:90px;">
                                            <span class="save" name="{$value.audience_id}" style="cursor:pointer">
                                                修改
                                            </span>
                                            |
                                            <span class="delete" id="{$value.audience_id}" name="{$value.audience_portrait}"  style="cursor:pointer">
                                                删除
                                            </span>
                                        </td>
                                    </tr>
                                </foreach>
                            </tbody>
                        </table>
                        <ul class="pagination success">{$rs.show}</ul>
                    </div>
                    <div class="table-responsive" id="hl"></div>
                </div>
            </div>
             <!--end cols-8-->
        </div>
    </div>
</div>
</body>
</html>
<script src="__PUBLIC__/Js/add_form.js"></script>
<script type="text/javascript">
$(".current").css({background:"#8CC152",color:"white"});
$('[name="audience_rights"]').change(function(){
	if($('[name="audience_rights"]').val()==2){
		$('[name="check_rights"]').each(function(index, element) {
            $(this).show();
        });
	}else{
		$('[name="check_rights"]').each(function(index, element) {
            $(this).hide();
        });
	}
});

//修改
$(".save").click(function(){
    var id = $(this).attr("name");
    $.ajax({
        url:"__URL__/to_update",
        data:{"audience_id":id},
        type:"get",
        success:function(data){
            $(".div1").css({display:"none"});
            $("#hl").html(data);
        }
    });
});
//删除
$(".delete").on("click",function(){
    var id = $(this).attr("id");
    if(confirm("确认删除?")){
        $.ajax({
            url:"__URL__/delAct",
            data:{"audience_id":id},
            type:"post",
            success:function(data){
                window.location="__SELF__";

            }
        })
    }
});


function excel_import()
{
	$("#title_name").text("Excel文件导入:");
	$(".input").html("<a href='__PUBLIC__/phpExcel/example.xls'>点击下载固定excel格式模板(限xls)</a><br/><br/><input style='margin-bottom:5px' class='local_name form-control must' id='local' type='file' name='excel' />");							
	$(".add_bg").css({display:"block"});
	$(".add_city").css({display:"block"});

	$(".sub_remove").click(function(){
		$(".add_bg").css({display:"none"});
		$(".add_city").css({display:"none"});
	});
}

//排序
$(".order").click(function(){
	var $order = '<php>echo $_GET["order"]</php>' == '' ? 'audience_id' : '<php>echo $_GET["order"]</php>';
	var $asc   = '<php>echo $_GET["asc"]</php>'   == '' ? 'desc' 		: '<php>echo $_GET["asc"]</php>';
	var $seach = '<php>echo $_GET["seach"]</php>' == '' ? '' 			: '<php>echo $_GET["seach"]</php>';
	var $page  = '<php>echo $_GET["page"]</php>'  == '' ? '' 			: '<php>echo $_GET["page"]</php>';
	var $name  = $(this).attr('name');
	if($name == $order){
		if($asc == 'asc')
			$asc = 'desc'
		else
			$asc = 'asc'
		window.location='__URL__/index?order='+$order+'&asc='+$asc+'&seach='+$seach+'&page='+$page;
	}else{
		$asc   = 'asc';
		$order = $name;
		window.location='__URL__/index?order='+$order+'&asc='+$asc+'&seach='+$seach+'&page='+$page;
	}
})
</script>